//
//  ChannelCollectionViewCell.m
//  Movie
//
//  Created by cjy on 16/3/25.
//  Copyright © 2016年 HY. All rights reserved.
//

#import "ChannelCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "ChannelModel.h"
@implementation ChannelCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    
    
    if (self) {
        
        self.img = [[UIImageView alloc]init];
        [self.contentView addSubview:self.img];
        
        self.title = [[UILabel alloc]init];
        [self.img addSubview:self.title];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{

    self.img.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    
    self.title.frame = CGRectMake(20, 120, self.contentView.frame.size.width, 20);
}

- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{

    return layoutAttributes;
}


- (void)passModel:(ChannelModel *)model{

    [self.img sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"zwt"]];
    
    self.title.text = model.title;
    self.title.textColor = [UIColor whiteColor];
}

@end
